/**
 * 二手市场 api 接口类
 * 
 * add by 吴学文 QQ 928255095
 */


import {
	requestNoAuth,
	request
} from '../../lib/java110/java110Request.js';
import url from '../../constant/url.js';


/**
 * 查询跳蚤市场东西
 * @param {Object} _data 查询 入参
 */
export function queryMarket(_data) {
	return new Promise((resolve, reject) => {
		request({
			url: url.listJunkRequirements,
			method: "GET",
			data: _data,
			success: function(res) {
				let data = res.data;
				resolve(data.junkRequirements);
			},
			fail: function(res) {
				reject(res);
			}
		});
	},err=>{
		console.log('err',err)
	})
}

/**
 *  标记完成
 */
export function finishMyJunk(dataObj) {
	return new Promise(
		(resolve, reject) => {
			request({
				url: url.updateJunkRequirement,
				method: "POST",
				data: dataObj,
				//动态数据
				success: function(res) {
					if (res.statusCode == 200) {

						resolve(res.data);
						return;
					}
					reject();
				},
				fail: function(e) {
					reject();
				}
			});
		})
}

/**
 *  删除发布
 */
export function deleteMyJunk(dataObj) {
	return new Promise(
		(resolve, reject) => {
			request({
				url: url.deleteJunkRequirement,
				method: "POST",
				data: dataObj,
				//动态数据
				success: function(res) {
					if (res.statusCode == 200) {
						resolve(res.data);
						return;
					}
					reject();
				},
				fail: function(e) {
					reject();
				}
			});
		})
}

/**
 *  删除发布
 */
export function submitMyJunk(dataObj) {
	return new Promise(
		(resolve, reject) => {
			request({
				url: url.saveJunkRequirement,
				method: "POST",
				data: dataObj,
				//动态数据
				success: function(res) {
					if (res.statusCode == 200) {
						resolve(res.data);
						return;
					}
					reject();
				},
				fail: function(e) {
					reject();
				}
			});
		})
}
